core: Add --no-xattrs option for commit
authorColin Walters <walters@verbum.org>
Thu, 5 Jan 2012 23:56:21 +0000 (18:56 -0500)
committerColin Walters <walters@verbum.org>
Fri, 6 Jan 2012 00:10:26 +0000 (19:10 -0500)
Will be used by ostbuild.

src/libostree/ostree-repo.c
src/libostree/ostree-repo.h
src/ostree/ot-builtin-commit.c
tests/t0000-basic.sh

index 71bf05553f23c38ea8b0db94c83f08b91b0a2223..92d15f4a0d172bb5ab7ac6849715a60040e20df6 100644 (file)
@@ -1452,9 +1452,12 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo           *self,
       
       modified_info = create_modified_file_info (child_info, modifier);
       
-      xattrs = ostree_get_xattrs_for_file (dir, error);
-      if (!xattrs)
-        goto out;
+      if (!(modifier && modifier->skip_xattrs))
+        {
+          xattrs = ostree_get_xattrs_for_file (dir, error);
+          if (!xattrs)
+            goto out;
+        }
       
       if (!stage_directory_meta (self, modified_info, xattrs, &child_file_checksum,
                                  cancellable, error))
@@ -1513,9 +1516,12 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo           *self,
                 goto out;
             }
 
-          xattrs = ostree_get_xattrs_for_file (child, error);
-          if (!xattrs)
-            goto out;
+          if (!(modifier && modifier->skip_xattrs))
+            {
+              xattrs = ostree_get_xattrs_for_file (child, error);
+              if (!xattrs)
+                goto out;
+            }
 
           if (!stage_object_impl (self, OSTREE_OBJECT_TYPE_RAW_FILE,
                                   modified_info, xattrs, file_input, NULL,
index 3777d8400b5dc7ac1fbe64499a258d5153c27728..c1a4ebbbd16061ffb8591fdb3acbc061145c2b5e 100644 (file)
@@ -137,10 +137,14 @@ gboolean      ostree_repo_load_variant (OstreeRepo  *self,
 
 typedef struct {
   volatile gint refcount;
-  gpointer reserved[3];
 
   gint uid;
   gint gid;
+
+  guint reserved_flags : 31;
+  guint skip_xattrs : 1;
+
+  gpointer reserved[3];
 } OstreeRepoCommitModifier;
 
 OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (void);
index e414a2c1669b242f76eb54372292626c6c35cf95..8b791189dd8f066f4f17989db33070a361bad326 100644 (file)
@@ -38,6 +38,7 @@ static char *branch;
 static char **metadata_strings;
 static gboolean skip_if_unchanged;
 static gboolean tar_autocreate_parents;
+static gboolean no_xattrs;
 static char **trees;
 static gint owner_uid = -1;
 static gint owner_gid = -1;
@@ -53,6 +54,7 @@ static GOptionEntry options[] = {
   { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &trees, "Overlay the given argument as a tree", "NAME" },
   { "owner-uid", 0, 0, G_OPTION_ARG_INT, &owner_uid, "Set file ownership user id", "UID" },
   { "owner-gid", 0, 0, G_OPTION_ARG_INT, &owner_gid, "Set file ownership group id", "GID" },
+  { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &no_xattrs, "Do not import extended attributes", NULL },
   { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
   { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL },
   { NULL }
index 2dff8ff980ac5e543ebfcd0a9a8c9b80b4f3cdcf..1514f3441f46d88b7f4ba007b16066d08a368a15 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -e
 
-echo "1..22"
+echo "1..23"
 
 . libtest.sh
 
@@ -169,3 +169,7 @@ $OSTREE show test2 > test2-commit-text
 assert_file_has_content test2-commit-text "'FOO'.*'BAR'"
 assert_file_has_content test2-commit-text "'KITTENS'.*'CUTE'"
 echo "ok metadata commit with strings"
+
+cd ${test_tmpdir}/checkout-test2-4
+$OSTREE commit -b test2 -s "no xattrs" --no-xattrs
+echo "ok commit with no xattrs"